
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>ambient.convert_units &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Overview of Chemical Properties" href="../../modules/chem.html" />
    <link rel="prev" title="ambient.compute_pressure" href="ambient.compute_pressure.html" />
   
  <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="ambient-convert-units">
<h1>ambient.convert_units<a class="headerlink" href="#ambient-convert-units" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="ambient.convert_units">
<code class="sig-prename descclassname">ambient.</code><code class="sig-name descname">convert_units</code><span class="sig-paren">(</span><em class="sig-param">data</em>, <em class="sig-param">units</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/ambient.html#convert_units"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#ambient.convert_units" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the values in data to standard units</p>
<p>This function accepts a data array with variables arranged in columns, 
each column given by the sequential unit in units, and converts the 
values in the array to standard units.  The function returns both the 
transformed data and the new, standardized units.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>data</strong><span class="classifier">int, float, list, or ndarray</span></dt><dd><p>Data in which the values in each column are of uniform 
units.</p>
</dd>
<dt><strong>units</strong><span class="classifier">string list</span></dt><dd><p>A list of strings stating the units of the input data array.  The 
squence of strings in the list must match the units of each column
of data</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>A tuple containing:</dt><dd></dd>
<dt><strong>data</strong><span class="classifier">ndarray</span></dt><dd><p>Array of data in the same order as the input array, but converted to
standard units.</p>
</dd>
<dt><strong>units</strong><span class="classifier">string list</span></dt><dd><p>A list of strings stating the new, standardized units of the values in 
data.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>This function assumes that for a one-dimensional array, each element has 
a unique unit.  That is, one-dimensional arrays are assumed to be rows
with the number of columns equal to the number of values.  If a single 
column of data must be converted, you may pass
<cite>numpy.atleast_2d(data).transpose()</cite>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">10</span><span class="p">,</span> <span class="mf">25.4</span><span class="p">,</span> <span class="mf">9.5</span><span class="p">,</span> <span class="mi">34</span><span class="p">],</span> <span class="p">[</span><span class="mi">100</span><span class="p">,</span> <span class="mf">10.7</span><span class="p">,</span> <span class="mf">8.4</span><span class="p">,</span> <span class="mf">34.5</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">units</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;m&#39;</span><span class="p">,</span> <span class="s1">&#39;deg C&#39;</span><span class="p">,</span> <span class="s1">&#39;mg/l&#39;</span><span class="p">,</span> <span class="s1">&#39;psu&#39;</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">data</span><span class="p">,</span> <span class="n">units</span> <span class="o">=</span> <span class="n">convert_units</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">units</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">data</span>
<span class="go">array([[  1.00000000e+01,   2.98550000e+02,   9.50000000e-03,</span>
<span class="go">          3.40000000e+01],</span>
<span class="go">       [  1.00000000e+02,   2.83850000e+02,   8.40000000e-03,</span>
<span class="go">          3.45000000e+01]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">units</span>
<span class="go">[&#39;m&#39;, &#39;K&#39;, &#39;kg/m^3&#39;, &#39;psu&#39;]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">data</span> <span class="o">=</span> <span class="mi">10</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;deg C&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">data</span><span class="p">,</span> <span class="n">units</span> <span class="o">=</span> <span class="n">convert_units</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">units</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">data</span>
<span class="go">array([283])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">units</span>
<span class="go">[&#39;K&#39;]</span>
</pre></div>
</div>
</dd></dl>

</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../../index.html">Documentation overview</a><ul>
  <li><a href="../../user_manual.html">TAMOC User Manual</a><ul>
  <li><a href="../../modules/ambient.html">Overview of Ambient Module</a><ul>
      <li>Previous: <a href="ambient.compute_pressure.html" title="previous chapter">ambient.compute_pressure</a></li>
      <li>Next: <a href="../../modules/chem.html" title="next chapter">Overview of Chemical Properties</a></li>
  </ul></li>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="../../_sources/autodoc/ambient/ambient.convert_units.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>